package com.dong.designpattern.singleton;

/**
 * 单例模式 - 饿汉式2
 * 和Singleton01一个意思
 *
 * @author by jiweidong on 2021/11/14.
 */
public class Singleton02 {

    private static final Singleton02 INSTANCE;
    static {
        INSTANCE = new Singleton02();
    }

    private Singleton02() {

    }

    public static Singleton02 getInstance() {
        return INSTANCE;
    }

    public static void main(String[] args) {
        Singleton02 s1 = Singleton02.getInstance();
        Singleton02 s2 = Singleton02.getInstance();

        System.out.println(s1 == s2);
    }
}
